import React, { useState } from 'react';
import { ConfigProvider, theme } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import Login from './pages/Login';
import MainLayout from './components/MainLayout';
import Dashboard from './pages/Dashboard';
import Album from './pages/Album';
import Gallery from './pages/Gallery';
import AccountSettings from './pages/AccountSettings';
import './App.css';

function App() {
    // 默认设置为未登录状态
    const [isAuthenticated, setIsAuthenticated] = useState(false);
    const [currentContent, setCurrentContent] = useState('dashboard');

    const handleLogin = () => {
        setIsAuthenticated(true);
    };

    const handleLogout = () => {
        setIsAuthenticated(false);
    };

    const renderContent = () => {
        switch (currentContent) {
            case 'dashboard':
                return <Dashboard />;
            case 'album':
                return <Album />;
            case 'gallery':
                return <Gallery />;
            case 'account':
                return <AccountSettings />;
            default:
                return <Dashboard />;
        }
    };

    return (
        <ConfigProvider
            theme={{
                algorithm: theme.darkAlgorithm,
                token: {
                    colorPrimary: '#1890ff',
                },
            }}
            locale={zhCN}
        >
            {!isAuthenticated ? (
                <Login onLogin={handleLogin} />
            ) : (
                <MainLayout
                    onLogout={handleLogout}
                    currentContent={currentContent}
                    setCurrentContent={setCurrentContent}
                >
                    {renderContent()}
                </MainLayout>
            )}
        </ConfigProvider>
    );
}

export default App; 